package com.wn.consumer;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author yellow Docter
 * @date 2023 -07-25
 * @desc
 */
@Component
public class MemberConsumer {

    /**
     *
     * @Queue        队列    存储消息
     * @Exchange     交换机  把消息转发到 队列
     * bindings 属性  把 Exchange 和队列进行绑定
     *
     *  @Queue(name = "member-queue")
     *       @Queue 队列的注解 name 队列的名称   如果是 消费端 (如果 没有队列\自动创建队列)
     *
     *  @Exchange(name = "exchange-fanout",type = ExchangeTypes.FANOUT)
     *       @Exchange 交换机注解   name 交换机名称 type 交换机类型 (FANOUT 广播交换机)
     *
     */
    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(name = "-queue"),
                    exchange = @Exchange(name = "exchange-fanout",type = ExchangeTypes.FANOUT)
            )
    )
    public void handlerMsg(String msg){

        System.out.println("MemberConsumer.handlerMsg--->"+msg);
    }

}
